import { http } from '@/utils/request'
import type { ISkuCommon, ISkuList } from '@/api/types'

/**
 * @description 获取 Sku 列表
 * @param page 页码，当前页
 * @param limit 每页展示多少条数据
 * @returns
 */
export const reqSkuList = (page: number, limit: number) => {
  return http<ISkuList>(`/admin/product/list/${page}/${limit}`, 'GET')
}

/**
 * @description 获取 Sku 详情
 * @param id
 * @returns
 */
export const reqSkuInfo = (id: number) => {
  return http<ISkuCommon>(`/admin/product/getSkuById/${id}`, 'GET')
}

/**
 * @description 新增 Sku
 * @param data
 * @returns
 */
export const reqSaveSku = (data: ISkuCommon) => {
  return http('/admin/product/saveSkuInfo', 'POST', data)
}

/**
 * @description 上架
 * @param id
 * @returns
 */
export const reqCancelSale = (id: number) => {
  return http(`/admin/product/cancelSale/${id}`, 'GET')
}

/**
 * @description 下架
 * @param id
 * @returns
 */
export const reqOnSale = (id: number) => {
  return http(`/admin/product/onSale/${id}`, 'GET')
}

/**
 * @description 下架
 * @param id
 * @returns
 */
export const reqDelSku = (id: number) => {
  return http(`/admin/product/deleteSku/${id}`, 'DELETE')
}
